package com.swadar.dao;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;



import com.swadar.beans.dataobject.BrandDO;

@Component
public class BrandDAO {
	
	@Autowired
	private JdbcTemplate jdbcTemplate;

	private final String GET_BRAND_NAME = "SELECT B.ID,B.NAME,BM.CATEGORY_ID FROM BRAND B JOIN BRAND_CATEGORY_MAPPING BM ON B.ID = BM.BRAND_ID WHERE BM.CATEGORY_ID = ?";
	
	public List<BrandDO> getBrandNameList(Long categoryId){
		Object[] param = { categoryId };
		BeanPropertyRowMapper<BrandDO> mapper = new BeanPropertyRowMapper<BrandDO>(BrandDO.class);
		List<BrandDO> brandNameList = jdbcTemplate.query(GET_BRAND_NAME, param, mapper);
		return brandNameList; 
	}
}
